import { createApp } from 'vue'
import App from './App.vue'
import store from './store'
import router from './router'
import axios from 'axios'

// 挂载应用
const app = createApp(App)

// 挂载store
store(app)

// 挂载router
router(app)

// 公共函数
import util from './util'
window.$util = util

// 公共插件
import plugins from './plugins'
Object.keys(plugins).forEach((key: string) => {
  const { plugin, option, component } = (plugins as any)[key]
  if (plugin) option ? app.use(plugin, option) : app.use(plugin)
  if (!component) return
  for (let comp in component) app.component(comp, component[comp])
})

// 公共组件
import components from './components'

// 公共样式
import './styles/index.scss'

// http 请求
import http, { api } from './api'
window.$http = http
window.$api = api
window.$axios = axios

app.use(components).mount('#app')
